package org.datamining.guha.association;

import java.util.List;
import java.util.ArrayList;

import org.datamining.guha.model.PatternTreeModel;
import org.datamining.guha.model.literal.Literal;

//import org.apache.commons.logging.*;

/**
 * Funded Implication. Also known as Simple p-implication.
 * See [Hajek]
 *
 * @author Lukas Vlcek
 */
public class FundedImplication extends AbstractAssociation {
    
    public FundedImplication(double support, double confidence) {
        super(support, confidence);
    }
    
    String associationDescription() {
        return "Funded Implication";
    }
    
    void ruleEvalutaion(PatternTreeModel ptm, int numberOfObjects) {
        
       if (log.isDebugEnabled()) {
            log.debug("antecedent " + antecedent);
            log.debug("succedent " + succedent);
        }
        
        List<Literal> a = antecedent;
        List<Literal> a_b = new ArrayList<Literal>(antecedent);
        a_b.addAll(succedent);

        //log.debug("Getting support of " + a);
        long suppA = ptm.getPatternSupport(a);
        //log.debug("Getting support of " + a_b);
        long suppAB = ptm.getPatternSupport(a_b);

        /* specific FIMPL calculations */
        ruleSupport = (double) suppAB/numberOfObjects;
        ruleConfidence = (double) suppAB/suppA;

        /*
        log.debug("Testing hypothesis: " + antecedent + " => " + succedent);
        log.debug("supp = " + ruleSupport);
        log.debug("conf = " + ruleConfidence);
        log.debug(" - - - - - - ");
        */
    }

}
